<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/base/jsp/include.jsp"%>
<style>

</style>
<script type="text/javascript">
    var id = "${id}";
    var submitForm = function($dialog, $grid, $pjq) {
        if ($('form').form('validate')) {
            var obj=sy.serializeObject($('form'));
            obj.activityTime+=":00";
            obj.image = $("#file_upload").getFileId();
            obj.type = $("#type").find("option:selected").val();
            obj.isAgree = 0;
            obj.kind = $("#kind").find("option:selected").val();
           /*  var deptNo2 = $("#deptSecNo").val();
            var deptNo = $("#deptId").val();
            if(deptNo2!=""){
            	obj.deptno = deptNo2
            }else{
            	obj.deptno = deptNo
            } */
            if(obj.type==1){
                if($("#file_upload").getFileId()){
                    $.messager.alert('Warning','转载请删除图片...');
                    return;
                }
            }
            var url=sy.contextPath + '/policy/myListSave.do';
            $.post(url, obj, function(result) {
                if (result.code == 0) {
                    $grid.datagrid('reload');
                    $dialog.dialog('destroy');
                } else {
                    $pjq.messager.e('添加失败,'+result.msg);
                }
            }, 'json');
        }
    }; 
    $(function() {
        if (id != '') {
            parent.$.messager.progress({
                text : '数据加载中....'
            });
            $.post(sy.contextPath + '/policy/findById.do', {
                id : id
            }, function(result) {
                if (result) {
                    $('form').form('load', result);
                    $('#file_upload').setFileId(result.image,true,true);
                }
                parent.$.messager.progress('close');
            }, 'json');
        }
        
        
    });
    $(function() {
        $('#deptId').combobox({
            url:sy.contextPath + '/dept/findDeptNo.do',
            valueField:'deptNo',
            textField:'deptName',
            onChange:function(data){
                $('#deptSecNo').combobox({
                    disabled:false,
                    valueField:'deptNo',
                    textField:'deptName',
                    url:sy.contextPath + '/dept/findSecondDeptno.do?id='+data,
                }); 
            }
        });
    });
</script>
</head>
<body>
    <form id="form" method="post">
        <input name="id" type="hidden" />
        <input name="fid" type="hidden" />
        <div style="padding:15px;font-size: 12px">
            <table style="table-layout:fixed;" border="0" cellspacing="0" class="formtable">
                <tr>
                    <th style="width:100px;" colspan="3">政策标题：</th>
                    <td>
                        <input class="easyui-textbox" id = "title" name = "title"  data-options="required:true,validType:'length[1,50]'" style="width:100%"/>
                    </td> 
                             
                </tr>
                <!-- <tr>
                    <th style="width:100px;" colspan="3">一级部门：</th>
                    <td>
                        <input class="easyui-combobox" id = "deptId" name = "deptName"  data-options="required:true,validType:'length[1,50]'" style="width:100%" editable="false"/>
                    </td> 
                             
                </tr>
                <tr>
                <tr>
	                <th style="width:100px;" colspan="3">二级部门：</th>
	                    <td>
	                        <input class="easyui-combobox" id = "deptSecNo" name = "deptNo2"  data-options="validType:'length[1,50]'" style="width:100%" editable="false"/>
	                    </td>
	                </tr> 
                <tr>  -->
                <tr>    
                    <th style="width:100px;" colspan="3">类型：</th>
                    <td>
                        <select class="easyui-combobox" id = "type" name = "type"  data-options="required:true,editable:false" style="width:100%">
                            <option value="0">发布</option>
                            <option value="1">转载</option>
                        </select>
                    </td>
                </tr>
                <tr>    
                    <th style="width:100px;" colspan="3">类别：</th>
                    <td>
                        <select class="easyui-combobox" id = "kind" name = "kind"  data-options="required:true,editable:false" style="width:100%">
                            <option value="发改">发改</option>
                            <option value="经信">经信</option>
                            <option value="科技">科技</option>
                            <option value="商务">商务</option>
                            <option value="人才">人才</option>
                            <option value="人社">人社</option>
                            <option value="团委">团委</option>
                            <option value="科协">科协</option>
                            <option value="工会">工会</option>
                            <option value="金融">金融</option>
                            <option value="其它">其它</option>
                        </select>
                    </td>
                </tr>
                <tr> 
                <th style="width:100px;" colspan="3">内容：</th>
                    <td>
                        <textarea class="easyui-textbox" id = "content" name = "content"  data-options="required:true,validType:'length[1,1500]',multiline:true" style="width:100%; height: 100px"></textarea>
                    </td>
                </tr> 
                <tr>    
                         
                    <th style="width:100px;" colspan="3">请选择图片：</th>
                    <td>
                        <input id="file_upload" name="image" fileCountLimit="9" formData='{"a":1}' multi="true" type="file" showBtn='true' bestSize='300*300'  showImage="true"  fileType="*.jpg;*.png" fileSize="500KB" buttonText="上传图片"/>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>